<template>

  <div class="container-fuild">
    <div class="row page-titles">
      <ol class="breadcrumb">
        <li class="breadcrumb-item active">实训班 /</li>
        <li class="breadcrumb-item">实训考勤</li>
      </ol>
    </div>
    <div class="row">
      <div class="card">
        <div class="card-header">
          <p class="card-title">我的考勤</p>
        </div>
        <div class="card-body custom-ekeditor">
          <div id="ckeditor">
            <el-table
                :data="tableData"
                style="width: 100% ;color: #7d94c0">
              <el-table-column
                  prop="className"
                  label="实训班"
                  width="280">
                <template slot-scope="scope">
                  <i class="el-icon-user"></i>
                  <span style="margin-left: 10px">{{ scope.row.className }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  label="开始日期"
                  width="180">
                <template slot-scope="scope">
                  <i class="el-icon-time"></i>
                  <span style="margin-left: 10px">{{ scope.row.startTime }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  label="结束日期"
                  width="180">
                <template slot-scope="scope">
                  <i class="el-icon-time"></i>
                  <span style="margin-left: 10px">{{ scope.row.endTime }}</span>
                </template>
              </el-table-column>
              <el-table-column
                  label="期数"
                  width="160">
                <template slot-scope="scope">
                  <span style="margin-left: 0px">{{ scope.row.period }}</span>
                </template>
              </el-table-column>
              <el-table-column label="学生考勤" :row-class-name="tableRowClassName" style="margin-left: 30px">
                <template slot-scope="scope">
                  <el-button size="mini" style="background-color: steelblue ;color: white"
                             @click="handleEdit(scope.$index, scope.row)">查看
                  </el-button>
                  <el-dialog title="学生考勤" :visible.sync="dialogVisible"style="font-weight: bold"
                             append-to-body width="70%" class="showAll_dialog">
                    <el-table :data="list2" style="width: 100%;margin-left: 20px;" :cell-style="cellStyle" >
                      <el-table-column label="日期" width="200" >
                        <template slot-scope="scope">
                          <span>{{ scope.row.date }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="上午" width="190">
                        <template slot-scope="scope">
                          <span>{{ scope.row.morning }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="下午" width="190">
                        <template slot-scope="scope">
                          <span>{{ scope.row.afternoon }}</span>
                        </template>
                      </el-table-column>
                      <el-table-column label="晚上" width="190">
                        <template slot-scope="scope">
                          <span>{{ scope.row.evening }}</span>
                        </template>
                      </el-table-column>
                    </el-table>
                    <span slot="footer" class="dialog-footer">
                       <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
                    </span>
                  </el-dialog>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </div>
      </div>
    </div>
  </div>

</template>

<script>

export default {
  name: "Attendance",
  data() {
    return {
      id:this.$route.query.id,
      dialogVisible: false,
      tableData: [{date: '2022-9-16'}],
      date: '',
      list2: [{date: 1}, {date: 2}],
      classname2:''
    }
  },
  mounted() {

    this.classShow();

  },
  methods: {
    classShow: function () {
      let that1 = this;
      this.axios.get('http://localhost:9090/user/getTrainClass/'+that1.id)
          .then(function (ret) {
            that1.tableData = ret.data.data;
          })
    },
    handleEdit(index, row,rowIndex) {
      // console.log(index, row,rowIndex);
      this.classname2 = row.className;
      // console.log(classname);
      this.dialogVisible = true;
      let that = this;
      this.axios.get('http://localhost:9090/user/getAttendance/'+ this.classname2 +'/'+this.id)
          .then(function (ret) {
            // console.log(ret.data.data);
            that.list2 = ret.data.data;
          }).catch(function (err) {
      })
    },
    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 1) {
        return 'warning-row';
      } else if (rowIndex === 3) {
        return 'success-row';
      }
      return '';
    },
    cellStyle({row, column, rowIndex, columnIndex}){
      // if(row.morning !== "正常" || row.afternoon !== "正常" || row.evening !== "正常"){ //指定坐标rowIndex ：行，columnIndex ：列
      //     return 'background-color:rgb(255 248 248);' //rgb(105,0,7)
      // }
      if((row.morning !== "正常" && columnIndex === 1)||(row.afternoon !== "正常" && columnIndex === 2)||(row.evening !== "正常" && columnIndex === 3)){
        return "color:#e26f6f;"
      }
      else return 'color:#7d94c0'
    }
  }
}
</script>

<style scoped>
/*表头*/
.container-fuild {

  float: left;
  /*padding-top:1.875rem;*/
  padding-right: 1.875rem;
  padding-left: 1.875rem;
  width: 93%;
  margin-right: auto;
  margin-left: auto;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.5;
  color: #7d94c0;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}

.page-titles {
  justify-content: space-between;
  /*padding: 0.1375rem 0.5rem;*/
  padding-top: 0.25rem;
  padding-right: 1.875rem;
  padding-bottom: 0.25rem;
  padding-left: 1.875rem;
  background: #fff;
  margin-bottom: 1.875rem;
  border-radius: 1rem;
  margin-top: 0;
  margin-left: 0;
  margin-right: 0;
  --bs-gutter-x: 30px;
  --bs-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
}

.page-titles .breadcrumb {
  margin-bottom: 0;
  padding: 0;
  background: transparent;
  font-size: 1.1875rem;
  display: flex;
  flex-wrap: wrap;
  padding: 0 0;
  margin-bottom: 1rem;
  list-style: none;
  flex-shrink: 0;
  width: 100%;
  max-width: 100%;
}

.breadcrumb li.active {
  font-weight: 600;
  font-size: 1.1875rem;
}

.breadcrumb li {
  margin-top: 0;
  margin-bottom: 0;
  padding-left: 0.5rem;
  font-size: 1.1875rem;
}

/*主题部分*/
.row {
  --bs-gutter-x: 30px;
  --bs-gutter-y: 0;
  display: flex;
  flex-wrap: wrap;
  margin-top: calc(var(--bs-gutter-y) * -1);
  margin-right: calc(var(--bs-gutter-x) / -2);
  margin-left: calc(var(--bs-gutter-x) / -2);
}

.card {
  width: 100%;
  margin-bottom: 1.875rem;
  background-color: #fff;
  transition: all .5s ease-in-out;
  position: relative;
  border: 0rem solid transparent;
  border-radius: 1.25rem;
  box-shadow: 0rem 0.3125rem 0.3125rem 0rem rgb(82 63 105 / 5%);
  height: calc(100% - 30px);

  display: flex;
  flex-direction: column;
  min-width: 0;
  word-wrap: break-word;
  background-color: #fff;
  background-clip: border-box;
}

.card-header {
  border-color: #f5f5f5;
  position: relative;
  background: transparent;
  padding-top: 0rem;
  padding-right: 1.875rem;
  padding-bottom: 0rem;
  padding-left: 1.875rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 1.1rem;
  font-weight: 300;
  color: #909399;
  text-transform: capitalize;
}

.card-body {
  padding-top: 0.125rem;
  padding-right: 1.875rem;
  padding-bottom: 1.125rem;
  padding-left: 1.875rem;

  flex-grow: 1;
  flex-shrink: 1;
  flex-basis: auto;
}

.table-responsive-md {
  min-width: 36rem !important;
}

/*弹窗*/
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}

/*让dialog能够悬浮在中间*/
.showAll_dialog {
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
}

::v-deep .el-dialog {
  margin: 0 auto !important;
  height: 80%;
  overflow: auto;
  background-color: white;
}

.el-dialog__body {
  position: absolute;
  left: 0;
  top: 54px;
  bottom: 0;
  right: 0;
  z-index: 1;
  overflow: hidden;
  overflow-y: auto;

  line-height: 30px;
  padding: 15px;
}

/*弹窗标题的padding*/
::v-deep .el-dialog__header {
  padding-top: 20px;
  padding-right: 50px;
  padding-bottom: 10px;
  padding-left: 50px;
}
/*弹窗标题的padding*/
::v-deep .el-dialog__header {
  padding-top: 30px;
  padding-right: 50px;
  padding-bottom: 30px;
  padding-left: 50px;
}

/*弹窗标题的颜色*/
::v-deep .el-dialog__title{
  color: #909399;
}

/*弹窗尾部按钮颜色*/
.el-button--primary {
  color: #FFF;
  background-color: #016bb7;
  border-color: #016bb7;
}


::v-deep .el-button{
  border-radius: 5px;
}
</style>